package com.wc.alorithm_luogu.P1980;

import java.util.Scanner;

/**
 * @Author congge
 * @Date 2023/4/20 11:02
 * @description https://www.luogu.com.cn/problem/P1980
 * 计数问题
 */
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int x = sc.nextInt();
        Main main = new Main();
        int ans = main.getNum(n, x);

        System.out.println(ans);
    }

    public int getNum(int n, int x) {
        int ans = 0;
        int tmp;
        for (int i = 1; i <= n; i++) {
            tmp = i;
            while (tmp != 0) {
                if (tmp % 10 == x) {
                    ans++;
                }
                tmp /= 10;
            }
        }
        return ans;
    }


}
